'use strict';

function grouping_count(collection) {
  var result=new Object();
  /*collection.sort();
  for(var i=0;i<collection.length;){
    var count=0;
    for(var n=i;n<collection.length;n++){
      if(collection[n]==collection[i]){
        count++;
      }      
    }
    result[collection[i]]=count;
    i+=count;
  }*/
  for(let item of collection){
    if(!result[item]){
      result[item]=1;
    }
    else{
      result[item]++;
    }
  }
  return result;
}
let a=[1,1,1,1,2,2,4,5,43,4]
console.log(grouping_count(a))
module.exports = grouping_count;
